#include "entry/ui/entryUI.h"

DoorWin::DoorWin(QMainWindow *parent):
NMainWindow(parent)
{

    config_fore = QMap<QString, QColor>({{MSEVKEY.WIN_NORMAL, QColor(12,15,22,200)},
                                         {MSEVKEY.WIN_PRESS, QColor(255,255,255)}});

    config_back = QMap<QString, QColor>({{MSEVKEY.WIN_NORMAL, QColor(255,255,255)},
                                         {MSEVKEY.WIN_PRESS, QColor(255,52,52)}});

    MapForStat[config_open] = true;

    QFont MangFont("KaiTi_GB2312", 11);
    FC_anlTool->setFont(MangFont);
    FC_player->setFont(MangFont);
    config_open->setFont(MangFont);
    config_save->setFont(MangFont);
    config_update->setFont(MangFont);
    config_reset->setFont(MangFont);
    HintPlEdit->setFont(MangFont);

    ToopHint = ToopHint.arg(SystemName, AmendDate, EditDate);

    FC_anlTool->setFixedHeight(30);
    FC_player->setFixedHeight(30);
    config_open->setFixedHeight(22);
    config_save->setFixedHeight(22);
    config_update->setFixedHeight(22);
    config_reset->setFixedHeight(22);

    HintPlEdit->setWordWrapMode(QTextOption::WrapAnywhere);
    HintPlEdit->setLineWidth(30);

    FC_anlTool->doconfigur_imgsetting(NT::DRAWTYPE_RECT, NT::PIXLOAD_IGNORERATIO_LOWER, 3, QPoint(5,0));
    FC_anlTool->doconfigur_text("小工具[anl、qr、sp]");
    FC_anlTool->doconfigur_textsetting(QPoint(5, 0));
    FC_anlTool->doconfigur_colorgroup({{MSEVKEY.WIN_NORMAL, QColor(151,151,151)},
                                       {MSEVKEY.WIN_ENTER, QColor(89,89,89)}});
    FC_anlTool->doconfigur_backcolorgroup({{MSEVKEY.WIN_NORMAL, QColor(255,255,255)},
                                           {MSEVKEY.WIN_ENTER, QColor(241,242,245)}});
    FC_anlTool->doconfigur_pixmapgroup({{MSEVKEY.WIN_NORMAL, ":/PIXMAP/bench/door-anlytool-dark.png"},
                                        {MSEVKEY.WIN_ENTER, ":/PIXMAP/bench/door-anlytool-enter.png"}});
    FC_anlTool->doconfigur_brighttype(NT::DRAWTYPE_RECT, 4, 1);
    FC_anlTool->doconfigur_bordercolorgroup({{MSEVKEY.WIN_NORMAL, QColor(132,157,199)},
                                             {MSEVKEY.WIN_ENTER, QColor(76,91,116)},
                                             {MSEVKEY.WIN_LEAVE, QColor(132,157,199)}});

    FC_player->doconfigur_imgsetting(NT::DRAWTYPE_RECT, NT::PIXLOAD_IGNORERATIO_LOWER, 3, QPoint(20,0));
    FC_player->doconfigur_text("播放器[media]");
    FC_player->doconfigur_textsetting(QPoint(5, 0));
    FC_player->doconfigur_imgsetting(QPoint(5,0));
    FC_player->doconfigur_colorgroup({{MSEVKEY.WIN_NORMAL, QColor(151,151,151)},
                                      {MSEVKEY.WIN_ENTER, QColor(89,89,89)}});
    FC_player->doconfigur_backcolorgroup({{MSEVKEY.WIN_NORMAL, QColor(255,255,255)},
                                          {MSEVKEY.WIN_ENTER, QColor(241,242,245)}});
    FC_player->doconfigur_pixmapgroup({{MSEVKEY.WIN_NORMAL, ":/PIXMAP/bench/door-player-dark.png"},
                                       {MSEVKEY.WIN_ENTER, ":/PIXMAP/bench/door-player-enter.png"}});
    FC_player->doconfigur_bordercolorgroup({{MSEVKEY.WIN_NORMAL, QColor(132,157,199)},
                                            {MSEVKEY.WIN_ENTER, QColor(76,91,116)},
                                            {MSEVKEY.WIN_LEAVE, QColor(132,157,199)}});
    FC_player->doconfigur_brighttype(NT::DRAWTYPE_RECT, 4);

    config_save->setEnabled(false);
    config_update->setEnabled(false);
    config_reset->setEnabled(false);

    config_open->doconfigur_textsetting(Qt::AlignCenter);
    config_save->doconfigur_textsetting(Qt::AlignCenter);
    config_update->doconfigur_textsetting(Qt::AlignCenter);
    config_reset->doconfigur_textsetting(Qt::AlignCenter);
    config_open->doconfigur_brighttype(NT::DRAWTYPE_RECT, 3);
    config_save->doconfigur_brighttype(NT::DRAWTYPE_RECT, 3);
    config_update->doconfigur_brighttype(NT::DRAWTYPE_RECT, 3);
    config_reset->doconfigur_brighttype(NT::DRAWTYPE_RECT, 3);
    config_open->doconfigur_bordercolorgroup({{MSEVKEY.WIN_NORMAL, QColor(132,157,199)},
                                             {MSEVKEY.WIN_ENTER, QColor(76,91,116)},
                                             {MSEVKEY.WIN_LEAVE, QColor(132,157,199)}});
    config_save->doconfigur_bordercolorgroup({{MSEVKEY.WIN_NORMAL, QColor(132,157,199)},
                                             {MSEVKEY.WIN_ENTER, QColor(76,91,116)},
                                             {MSEVKEY.WIN_LEAVE, QColor(132,157,199)}});
    config_update->doconfigur_bordercolorgroup({{MSEVKEY.WIN_NORMAL, QColor(132,157,199)},
                                             {MSEVKEY.WIN_ENTER, QColor(76,91,116)},
                                             {MSEVKEY.WIN_LEAVE, QColor(132,157,199)}});
    config_reset->doconfigur_bordercolorgroup({{MSEVKEY.WIN_NORMAL, QColor(132,157,199)},
                                             {MSEVKEY.WIN_ENTER, QColor(76,91,116)},
                                             {MSEVKEY.WIN_LEAVE, QColor(132,157,199)}});

    config_open->doconfigur_backcolorgroup(config_back);
    config_open->doconfigur_colorgroup(config_fore);
    config_save->doconfigur_colorgroup(config_fore);
    config_update->doconfigur_colorgroup(config_fore);
    config_reset->doconfigur_colorgroup(config_fore);
    config_open->doconfigur_textsetting(Qt::AlignCenter);
    config_save->doconfigur_textsetting(Qt::AlignCenter);
    config_update->doconfigur_textsetting(Qt::AlignCenter);
    config_reset->doconfigur_textsetting(Qt::AlignCenter);

    config_open->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
    config_save->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
    config_update->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
    config_reset->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);

    CfgFuncHLayout->addWidget(config_open);
    CfgFuncHLayout->addWidget(config_save);
    CfgFuncHLayout->addWidget(config_update);
    CfgFuncHLayout->addWidget(config_reset);
    DoorGrid->addWidget(FC_anlTool, 1, 0, 1, 1);
    DoorGrid->addWidget(FC_player, 1, 1, 1, 1);
    DoorGrid->addWidget(HintPlEdit, 3, 0, 1, 2);
    DoorGrid->addLayout(CfgFuncHLayout, 7, 0, 1, 2, Qt::AlignBottom);
    CfgFuncHLayout->setContentsMargins(0, 0, 0, 0);
    setCentralWidget(DoorWidget);

    d_margin_radius(QMargins(3, 0, 3, 3), 10);
    d_filler_enable(NTitleBar::BACKCOLOR, true); //可选背景色和背景图两个模式
    d_filler_color(QColor(251,252,253)); //背景色
    captionBar()->setFixedHeight(36); //设置标题栏高，默认是28
    captionBar()->d_margin_radius(QMargins(3, 0, 3, 3), 6);
    captionBar()->d_filler_enable(NTitleBar::BACKCOLOR, true);
    captionBar()->d_filler_color(QColor(251,252,253));
    captionBar()->d_caption("Harbor", QFont("PMingLiu", 10), QColor(120,120,120)); //设置标题栏文字
    captionBar()->d_captionico(":/PIXMAP/bench/scale2.ico");
    captionBar()->d_filler_enable(NTitleBar::BACKCOLOR, true); //设置标题栏填充为背景色模式
    captionBar()->d_basicbuttom_freepixmap(NTitleBar::NORWIN, 4, qRgb(49,49,49));
    captionBar()->d_basicbuttom_freepixmap(NTitleBar::MINWIN, 4, qRgb(49,49,49));
    captionBar()->d_basicbuttom_freepixmap(NTitleBar::MAXWIN, 4, qRgb(49,49,49));
    captionBar()->d_basicbuttom_freepixmap(NTitleBar::QUITE,  4, qRgb(49,49,49));
    captionBar()->d_basicbuttom_configur(NT::PIXLOAD_IGNORERATIO_LOWER, NT::DRAWTYPE_RECT, 8, 1.5);
    captionBar()->d_basicbuttom_where({NTitleBar::Rroof_Normal,
                                       NTitleBar::Rroof_Min,
                                       NTitleBar::Rroof_Max,
                                       NTitleBar::Rroof_Exit},
                                      {QString(MSEVKEY.WIN_NORMAL),
                                       QString(MSEVKEY.WIN_LEAVE),
                                       QString(MSEVKEY.WIN_PRESS),
                                       QString(MSEVKEY.WIN_RELEASE)});

    //systemtray_menuconfig
    if (TrayIco->isSystemTrayAvailable())
    {
        SystemTrayMenu->setStyleSheet(QSSMAP["Window_TrayMenu"]);
        QMenu *ScdMenu = SystemTrayMenu->addMenu("主窗口");
        ScdMenu->addAction(new QAction("正常", ScdMenu));
        ScdMenu->addAction(new QAction("最大化",ScdMenu));
        ScdMenu->addAction(new QAction("最小化",ScdMenu));
        ScdMenu->addAction(new QAction("退出", ScdMenu));
        QAction *SystemQuiet = SystemTrayMenu->addAction("退出");
        connect(SystemQuiet, &QAction::triggered, this, &DoorWin::close);
        TrayIco->showMessage("SoftVessel", ToopHint, QIcon(":/PIXMAP/bench/scale4.ico"), 8000);
        TrayIco->setIcon(QIcon(":/PIXMAP/bench/scale4.ico"));
        TrayIco->setToolTip(ToopHint);
        TrayIco->setContextMenu(SystemTrayMenu);
        TrayIco->setVisible(true);
    }
    diary("doorgui loding finishing and active visible", Diary::Debug)
}

DoorWin::~DoorWin(){
    delete CfgFuncHLayout;
}


